package com.dream.keigezhushou.Activity.kege.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dream.keigezhushou.R;

/**
 * Created by Administrator on 2017/3/17.
 */
public class JoinChorusAdapter extends BaseAdapter {

    private Context mContext;
    int c = 12;
    int postion;
    public ItemOnClickListening itemOnClickLinister = null;


    public void setItemOnClickListening(ItemOnClickListening listening) {
        this.itemOnClickLinister = listening;
    }

    public JoinChorusAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return c;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        postion = i;
        ProHolder mHolder = null;
        if (view == null) {
            view = LayoutInflater.from(mContext).inflate(R.layout.item_my_singing, null);
            mHolder = new ProHolder();
            mHolder.itemLinear = (LinearLayout) view.findViewById(R.id.item_my_singing_linear);
            mHolder.singingJoinTv = (TextView) view.findViewById(R.id.my_singing_join);
            view.setTag(mHolder);
        } else {
            mHolder = (ProHolder) view.getTag();
        }

        mHolder.singingJoinTv.setText("加入合唱");
        mHolder.itemLinear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (itemOnClickLinister != null) {
                    itemOnClickLinister.itemClick(postion);
                }
            }
        });

        mHolder.singingJoinTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (itemOnClickLinister!=null){

                    itemOnClickLinister.singingJoinClick(postion);

                }

            }
        });

        return view;
    }


    class ProHolder {

        LinearLayout itemLinear;
        TextView singingJoinTv;


    }


    public interface ItemOnClickListening {
        public void itemClick(int postion);

        public void singingJoinClick(int postion);
    }

}